﻿#include "CameraScreenInfo.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QDebug>

namespace Qly {
CameraScreenInfo::CameraScreenInfo(const CameraScreenInfo &info)
    :m_screen(nullptr)
{
    m_screen = info.m_screen;
}

CameraScreenInfo::CameraScreenInfo(QScreen * screen)
    :m_screen(nullptr)
{
    m_screen = screen;
}

bool CameraScreenInfo::isNull() const
{
    return (m_screen == nullptr);
}

QString CameraScreenInfo::description() const
{
    return "";
}
QString CameraScreenInfo::deviceName() const
{
    if(m_screen == nullptr) return "";
    return m_screen->name();
}

CameraScreenInfo CameraScreenInfo::defaultCamera()
{
    QScreen * w = QGuiApplication::primaryScreen();
    return CameraScreenInfo(w);
}

QList<CameraScreenInfo> CameraScreenInfo::availableCameras()
{
    QList<QScreen *> list = QGuiApplication::screens();
    QList<CameraScreenInfo> info;
    foreach (QScreen * s, list)
    {
        CameraScreenInfo i(s);
        info.append(i);
    }

    return info;
}

bool CameraScreenInfo::operator!=(const CameraScreenInfo &other) const
{
    return (m_screen != other.m_screen);
}

CameraScreenInfo & CameraScreenInfo::operator=(const CameraScreenInfo &other)
{
    m_screen = other.m_screen;
    return *this;
}

bool CameraScreenInfo::operator==(const CameraScreenInfo &other) const
{
    return m_screen == other.m_screen;
}

}
